<%@ page contentType="text/html;charset=UTF-8" language="java"%>
<%@  taglib  prefix="c"  uri="http://java.sun.com/jsp/jstl/core" %>
<html>
<head>
<meta charset="utf-8">
<title>我的关注</title>
<link rel="stylesheet" href="css/showcart.css" />
<link rel="stylesheet" type="text/css" href="css/main.css" />
<script src="js/imgs.js" type="text/javascript" charset="utf-8"></script>
<script src="js/jquery.js" type="text/javascript" charset="utf-8"></script>


<script>
    window.onload=function footer_img_non(){
      document.getElementById("footer_img").style.display="none";
    }
  </script>
</head>
<body onload="money()">
	<div class="con">
		<div class="head">
			<a href="index.jsp"> <img src="img/logo_login.png" alt="" />
			</a>
		</div>
		<div class="shop_box">
			<div class="head_text_box">
				<span id="head_text"> 我的关注 </span>
			</div>

			<div class="shop_title">
				<div id="st1">商品</div>
				<div id="st2">规格</div>
				<div id="st3">单价</div>
				<div id="st4">数量</div>
				<div id="st5">小计</div>
				<div id="st6">操作</div>
			</div>
			<script type="text/javascript">
			function   removebysid(sid){
				
				
				
			}
				
			</script>
			<c:forEach  items="${povos}"  var="povo">
				<div class="shop">
					<div class="s1">
						<div class="s1_img">
							<a href="/fruits/fruit/SearchFruitByFidServlet?fid=${povo.fruit.fid}"><img
								src="img/fruits/${povo.fruit.fid}/(1).jpg" /></a>
						</div>
						<div class="s1_text">
							<a href="/fruits/fruit/SearchFruitByFidServlet?fid=${povo.fruit.fid}">${povo.fruit.fname}</a>
						</div>
					</div>
	
					<div class="s2">${povo.fruit.fnorm}</div>
	
					<div class="s3">
						￥<span id="${povo.star.sid}up1">${povo.fruit.fprice}</span>
					</div>
					<div class="s4">
						<div class="Unum">
							<span id="${povo.star.sid}numl" class="numl" >-</span>
							<span id="${povo.star.sid}num1">${povo.star.scount}</span>
							<span id="${povo.star.sid}numr" class="numr" >+</span>
						</div>
					</div>
					<div class="s5">
						￥<span id="${povo.star.sid}sum1" class="fsum">${povo.total}</span>
					</div>
	
					<div class="s6">
						<a id="${povo.star.sid}" class="a"  href="#">删除</a>
					</div>
				</div>

			</c:forEach>
			
			
			<div class="shop_footer">&nbsp;</div>
		</div>

	</div>
	<jsp:include page="footer/footer.jsp"></jsp:include>
	<script type="text/javascript">
	//当前 showstar 页面  加载完毕后，  就   调用如下的  js
		$(function(){
			
			$(".a").click(function(){
				var   sid =  $(this).attr("id");
				//alert(sid);
				if(confirm("确认删除吗？")){
					location.href= "/fruits/star/RemoveStarBySidServlet?sid="+sid;
					
				}
				
			});
			
			//jia
			$(".numr").click(function(){
				var  sid =   $(this).attr("id").substr(0,32);
				
				$.ajax({
					
					cache: false ,
					async: false,
					dataType: "json",
					type: "post",
					data:{"key":"jia","sid":sid},
					url:  "/fruits/star/ChangeCountBySidServlet",
					
					success: function(){
						$("#"+sid+"num1").text(parseInt($("#"+sid+"num1").text())+1);
						
						var   price =  parseFloat($("#"+sid+"up1").text()) ;
						var   count  =  parseInt($("#"+sid+"num1").text());
						
						
						$("#"+sid+"sum1").text(price*count);
						
					}
					
				});
				
				
				
			});
			
			
			
			
			
			
			
			//jian
			$(".numl").click(function(){
				var   sid  =  $(this).attr("id").substr(0,32);
				//   ajax    异步请求    
				$.ajax({
					//要求浏览器不缓存  响应结果
					cache: false ,
					//是否异步 ，  false  同步
					async: false,
					//http请求的类型
					type: "post",
					//发送数据的 格式
					dataType: "json",
					//发送的数据
					data:{"key":"jian","sid":sid},
					// 请求的路径url
					url:"/fruits/star/ChangeCountBySidServlet",
					//  得到成功响应后，要执行的方法
					success: function(){
						//修改数量 -1   #开头是表示  id选择器，后面跟 id的值
						var  count   = parseInt($("#"+sid+"num1").text());				
						$("#"+sid+"num1").text(count-1);					
						// 计算  小计			
						var  price = parseFloat($("#"+sid+"up1").text());				
						count =  count -1 ;				
						var  total  =   (count *   price).toFixed(2);		
						$("#"+sid+"sum1").text(total);										
					}		
				});
				if(parseInt($("#"+sid+"num1").text())<1){
					location.href =  "/fruits/star/RemoveStarBySidServlet?sid="+sid;
				}			
			});	
		});
	
	</script>
	
	
</body>
</html>
